package practice;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class _10CrossRoad {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<Integer,Integer> map = new HashMap<>();
        int res = 0;
        for (int i = 0;i < n;i++){
            int id = scanner.nextInt();
            int position = scanner.nextInt();
            if (!map.containsKey(id)){
                map.put(id,position);
            }else {
                //  哈希表中已经有的该奶牛
                if (map.get(id) != position){
                    map.put(id,position);
                    res++;
                }
            }
        }
        System.out.println(res);
    }
}
